from sqlalchemy import Column, Integer, String, DateTime, JSON, func, TEXT, Text, Boolean

from server.db.base import Base


class MessageModel(Base):
    """
    聊天记录模型
    """
    __tablename__ = 'llm_message'
    id = Column(String(36), primary_key=True, comment='聊天记录ID')
    conversation_id = Column(String(32), default=None, index=True, comment='对话框ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    # 记录知识库id等，以便后续扩展
    meta_data = Column(JSON, default={})
    # 满分100 越高表示评价越好
    feedback_score = Column(Integer, default=-1, comment='用户评分')
    feedback_reason = Column(String(255), default="", comment='用户评分理由')
    create_time = Column(DateTime, default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<message(id='{self.id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}',meta_data='{self.meta_data}',feedback_score='{self.feedback_score}',feedback_reason='{self.feedback_reason}', create_time='{self.create_time}')>"


class CustomMessageModel(Base):
    """
    自定义聊天记录模型(用于用户在闲聊模式跟自己宠物对话)
    """
    __tablename__ = 'history_message_check'  # 历史聊天记录表名
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<CustomMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsZhiLiaoMessageModel(Base):
    """
    与星星火火智聊的聊天记录模型
    """
    __tablename__ = 'mars_zhiliao_history_message'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsZhiLiaoMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"

class MarsChatWithXingXingMessageModel(Base):
    """
    与星星对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_xingxing'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithXingXingMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsChatWithHuoHuoMessageModel(Base):
    """
    与火火对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_huohuo'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithHuoHuoMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsChatWithGuiJiHuoHuoMessageModel(Base):
    """
    与柜机火火对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_guiji_huohuo'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithGuiJiHuoHuoMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsChatWithGuiJiXingXingMessageModel(Base):
    """
    与柜机星星对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_guiji_xingxing'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithGuiJiXingXingMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsChatWithOtherPetMessageModel(Base):
    """
    与他人宠物对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_other_pet'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    pet_id = Column(String(64), index=True, comment='宠物ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsOfflineKBChatMessageModel(id='{self.id}', user_id='{self.user_id}', pet_id='{self.pet_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsTrainModeKBChatMessageModel(Base):
    """
    与自己宠物对话的训练模式聊天记录模型
    """
    __tablename__ = 'mars_training_mode_chat'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    pet_query = Column(TEXT, comment='宠物说的话')
    query = Column(TEXT, comment='用户说的话')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsTrainModeKBChatMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', pet_query='{self.pet_query}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsChatWithOwnPetMessageModel(Base):
    """
    与自己宠物对话的闲聊模式聊天记录模型
    """
    __tablename__ = 'mars_chat_with_own_pet'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsPersonalKBChatMessageModel(id='{self.id}', user_id='{self.user_id}', pet_id='{self.pet_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"

class MarsChatWithXiYangYangMessageModel(Base):
    """
    与全运会喜洋洋对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_xiyangyang'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithXiYangYangMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"
    
class MarsChatWithLeRongRongMessageModel(Base):
    """
    与全运会乐融融对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_lerongrong'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithLeRongRongMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"
    

class MarsChatWithPandoMessageModel(Base):
    """
    与奥林匹斯pando对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_pando'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithPandoMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"


class MarsChatWithPandyMessageModel(Base):
    """
    与电竞熊猫pandy对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_pandy'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithPandyMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"

class MarsChatWithMuDanHelenMessageModel(Base):
    """
    与牡丹Helen对话的聊天记录模型
    """
    __tablename__ = 'mars_chat_with_mudan_helen'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键递增ID')
    user_id = Column(String(64), index=True, comment='用户ID')
    conversation_id = Column(String(128), default=None, index=True, comment='对话ID')
    # chat/agent_chat等
    chat_type = Column(String(50), comment='聊天类型')
    query = Column(TEXT, comment='用户问题')
    response = Column(TEXT, comment='模型回答')
    instruction = Column(String(50), default="-1", comment='指令')
    knowledge_base_name = Column(String(50), default="", comment='知识库名称')
    create_time = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')

    def __repr__(self):
        return f"<MarsChatWithMuDanHelenMessageModel(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}', instruction='{self.instruction}', knowledge_base_name='{self.knowledge_base_name}', create_time='{self.create_time}')>"

"""
以下是阿里云百炼的智能体聊天记录模型
------------------------------------------------------------------------------
"""

class MarsXChatWithOwnPetSession(Base):
    """
    与自己宠物对话的会话模型
    """
    __tablename__ = "marsx_chat_with_own_pet_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXChatWithOwnPetSession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class MarsXChatWithOtherPetSession(Base):
    """
    与他人宠物对话的会话模型
    """
    __tablename__ = "marsx_chat_with_other_pet_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    pet_id = Column(String(255), index=True, comment="宠物ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXChatWithOtherPetSession(id='{self.id}', user_id='{self.user_id}', pet_id='{self.pet_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class MarsXTrainModeSession(Base):
    """
    训练模式会话模型
    """
    __tablename__ = "marsx_train_mode_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    user_input = Column(Text, comment="用户输入")
    pet_input = Column(Text, comment="宠物输入")
    memory_node_id = Column(String(255), comment="记忆片段ID")
    summary = Column(Text, comment="总结")
    relevant = Column(Text, comment="相关性")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    train_type = Column(String(255), comment="训练类型")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXTrainModeSession(id='{self.id}', user_id='{self.user_id}', user_input='{self.user_input}', pet_input='{self.pet_input}', memory_node_id='{self.memory_node_id}', summary='{self.summary}', relevant='{self.relevant}', request_id='{self.request_id}', request_type='{self.request_type}')>"


class MarsXChatWithXingXingSession(Base):
    """
    与星星对话的聊天记录模型
    """
    __tablename__ = "marsx_chat_with_xingxing_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXChatWithXingXingSession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"


class MarsXChatWithHuohuoSession(Base):
    """
    与火火对话的聊天记录模型
    """
    __tablename__ = "marsx_chat_with_huohuo_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXChatWithHuoHuoSession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class MarsXChatWithPandySession(Base):
    """
    与奥运电竞pandy对话的聊天记录模型
    """
    __tablename__ = "marsx_chat_with_pandy_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXChatWithPandySession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class MarsXChatWithPandoSession(Base):
    """
    与奥林匹斯pando对话的聊天记录模型
    """
    __tablename__ = "marsx_chat_with_pando_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXChatWithPandoSession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class MarsXChatWithLerongrongSession(Base):
    """
    与全运会乐融融对话的聊天记录模型
    """
    __tablename__ = "marsx_chat_with_lerongrong_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")

    def __repr__(self):
        return f"<MarsXChatWithLerongrongSession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class MarsXChatWithXiyangyangSession(Base):
    """
    与全运会喜洋洋对话的聊天记录模型
    """
    __tablename__ = "marsx_chat_with_xiyangyang_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")
    
    def __repr__(self):
        return f"<MarsXChatWithXiyangyangSession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class MarsXChatWithMuDanHelenSession(Base):
    """
    与牡丹Helen对话的聊天记录模型
    """
    __tablename__ = "marsx_chat_with_mudan_helen_session"
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False)  # 新增过期状态字段
    request_id = Column(String(255), comment="请求ID")
    instruction = Column(String(255), comment="指令")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")
    
    def __repr__(self):
        return f"<MarsXChatWithMuDanHelenSession(id='{self.id}', user_id='{self.user_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"

class GenericAgentChatSession(Base):
    """
    通用智能体对话会话模型
    """
    __tablename__ = "generic_agent_chat_session"
    # 自增ID
    id = Column(Integer, autoincrement=True, primary_key=True, index=True, comment="自增ID")
    user_id = Column(String(255), index=True, comment="用户ID")
    app_id = Column(String(255), index=True, comment="智能体ID")
    conversation_id = Column(String(255), index=True, comment="会话ID")
    user_input = Column(Text, comment="用户输入")
    assistant_answer = Column(Text, comment="智能体回答")
    is_expired = Column(Boolean, default=False, comment="是否过期")
    request_id = Column(String(255), comment="请求ID")
    pipeline_ids = Column(String(500), comment="知识库ID列表（逗号分隔）")
    created_time = Column(DateTime, default=func.now(), comment="创建时间")
    
    def __repr__(self):
        return f"<GenericAgentChatSession(id='{self.id}', user_id='{self.user_id}', app_id='{self.app_id}', conversation_id='{self.conversation_id}', request_id='{self.request_id}', user_input='{self.user_input}', assistant_answer='{self.assistant_answer}')>"